﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain;
using System.Data.SqlClient;

namespace DataAcess
{
    public class CaracteristicaData
    {
        public String literalConexion;

        public CaracteristicaData(String literalConexion)
        {
            this.literalConexion = literalConexion;
        
        }

        public String GetCaracteristicas(int idHabitacion)
        {
          
            String SqlSelect = "Select c.descripcion_caracteristica " + 
                           " From CaracteristicaHab c, CaracteristicaHab_TipoHab cth " +
                           " where c.id_caracteristica=cth.id_caracteristica and cth.id_tipoHabitacion=" + idHabitacion;

            SqlConnection conexion = new SqlConnection(literalConexion);
            SqlCommand cmdSelect = new SqlCommand(SqlSelect, conexion);
            conexion.Open();
            SqlDataReader reader = cmdSelect.ExecuteReader();
            String caracteristicas = null;
            //LinkedList<Caracteristica> caracteristicas=new LinkedList<Caracteristica>();

            while (reader.Read())
            {
                Caracteristica caracteristicaHab = new Caracteristica();
                caracteristicaHab.Descripcion = reader.GetString(0);
                caracteristicas +=" * " + caracteristicaHab.Descripcion + "\n";
                //caracteristicas.AddLast(caracteristicaHab);
            }
            conexion.Close();
            return caracteristicas;
        }
    }
}
